package com.cskaoyan.config;

import com.cskaoyan.interceptor.LoginHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author stone
 * @date 2022/06/01 16:26
 */
@EnableWebMvc //mvc:annotation-driven; 也会把当前类注册为容器中的组件； 也会当做是配置类
@ComponentScan("com.cskaoyan.controller")
public class MvcConfiguration implements WebMvcConfigurer {


    @Autowired
    LoginHandlerInterceptor handlerInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // HandlerInterceptor是谁？作用范围是什么？顺序？
        registry.addInterceptor(handlerInterceptor)/*.excludePathPatterns("/login")*/; // 作用范围是/**

    }
}
